﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Windows;
//using System.Windows.Controls;
//using System.Windows.Data;
//using System.Windows.Documents;
//using System.Windows.Input;
//using System.Windows.Media;
//using System.Windows.Media.Imaging;
//using System.Windows.Navigation;
//using System.Windows.Shapes;
//using System.Windows.Media.Media3D;

//namespace WpfDrawing
//{
//    /// <summary>
//    /// Interaction logic for MainWindow.xaml
//    /// </summary>
//    public partial class MainWindow : Window
//    {
//        /// <summary>
//        /// Gets or sets the model.
//        /// </summary>
//        /// <value>The model.</value>
//        public Model3D Model { get; set; }

//        public MainWindow()
//        {
//            InitializeComponent();

//            this.DataContext = this;
//        }

//        private IList<Point> points = new List<Point>();

//        private Polyline line = null;
//        private Polygon poly = null;
//        private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
//        {
//            if (e.LeftButton == MouseButtonState.Pressed)
//            {
//                Point point = Mouse.GetPosition(this);
//                points.Add(point);

//                if (line == null)
//                {
//                    line = new Polyline();
//                    line.Stroke = Brushes.White;
//                    line.StrokeThickness = 2;
//                    Canvas.Children.Add(line);
//                }
//                line.Points.Add(point);
//            }
//            if (e.RightButton == MouseButtonState.Pressed)
//            {
//                Canvas.Children.Remove(line);
//                line = null;

//                poly = new Polygon();
//                poly.Points = new PointCollection(points);
//                poly.Stroke = Brushes.Black;
//                poly.StrokeThickness = 2;
//                poly.Fill = Brushes.Yellow;

//                points = new List<Point>();
//                Canvas.Children.Add(poly);
//            }

//        }

//        private void Canvas_MouseMove(object sender, MouseEventArgs e)
//        {

//        }

//        private void button1_Click(object sender, RoutedEventArgs e)
//        {
//            Viewport3D viewPort = new Viewport3D();
//            PerspectiveCamera camera = new PerspectiveCamera();
//            DirectionalLight diLight = new DirectionalLight();
//            AmbientLight light = new AmbientLight();
//            Model3DGroup cube = new Model3DGroup();
//            ModelVisual3D modelVisual3D = new ModelVisual3D();
//            Model3DGroup group = new Model3DGroup();

//            GeometryModel3D geometry = new GeometryModel3D();
//            MeshGeometry3D mesh = new MeshGeometry3D();
//            DiffuseMaterial material = new DiffuseMaterial();

//            // nastaveni kamery
//            camera.Position = new Point3D(-500, -500, 500);
//            camera.LookDirection = new Vector3D(500, 500, -500);
//            camera.UpDirection = new Vector3D(0, 0, 1);

//            // nastaveni svetla
//            diLight.Color = Colors.White;
//            diLight.Direction = new Vector3D(-1, -1, -3);
//            //light.Color = Colors.Purple;

//            // group.Children.Add(light);
//            group.Children.Add(diLight);
//            group.Children.Add(cube);

//            // nastaveni geometrie
//            geometry.Geometry = mesh;

//            material.Brush = Brushes.Aqua;

//            // nastaveni barvy
//            geometry.Material = material;
//            geometry.BackMaterial = new DiffuseMaterial(Brushes.Yellow);

//            // body
//            int i = 0;
//            foreach (Point point in poly.Points)
//            {
//                mesh.Positions.Add(new Point3D(point.X, point.Y, 0));
//                mesh.Positions.Add(new Point3D(point.X, point.Y, 50));

//                i += 2;
//            }

//            // trojuhelniky
//            //mesh.TriangleIndices;
//            for (int j = 0; j < i; j++)
//            {
//                if (j % 2 == 0)
//                {
//                    mesh.TriangleIndices.Add(j % i);
//                    mesh.TriangleIndices.Add((j + 1) % i);
//                    mesh.TriangleIndices.Add((j + 3) % i);

//                    mesh.TriangleIndices.Add(j % i);
//                    mesh.TriangleIndices.Add((j + 3) % i);
//                    mesh.TriangleIndices.Add((j + 2) % i);
//                }
//            }

//            // mesh.TriangleIndices
//            //mesh.TriangleIndices.Add(0);
//            //mesh.TriangleIndices.Add(1);
//            //mesh.TriangleIndices.Add(2);
//            //mesh.TriangleIndices.Add(3);
//            //mesh.TriangleIndices.Add(4);
//            //mesh.TriangleIndices.Add(5);

//            // normaly
//            //mesh.Normals.Add(new Vector3D(0, 0, -1));
//            //mesh.Normals.Add(new Vector3D(0, 0, -1));
//            //mesh.Normals.Add(new Vector3D(0, 0, -1));
//            //mesh.Normals.Add(new Vector3D(0, 0, -1));
//            //mesh.Normals.Add(new Vector3D(0, 0, -1));
//            //mesh.Normals.Add(new Vector3D(0, 0, -1));

//            /// NOrmaly
//            //mesh.Normals;

//            cube.Children.Add(geometry);
//            modelVisual3D.Content = group;
//            ThreeDim.Camera = camera;
//            ThreeDim.Children.Add(modelVisual3D);

//            ThreeDim.Visibility = System.Windows.Visibility.Visible;
//            Canvas.Visibility = Visibility.Hidden;
//        }
//    }
//}
